package com.kundi.dooradmin.dao;

import com.kundi.dooradmin.entity.User;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserDao extends JpaRepository<User, Integer> {
    @Query(value = "select id from tb_user where username = :username", nativeQuery = true)
    List<Integer> getIdByUsername(@Param("username") String username);

    @Query(value = "select * from tb_user", nativeQuery = true)
    List<User> getAllUser();

    @Query(value = "select * from tb_user where id = :id", nativeQuery = true)
    User getUserById(@Param("id") Integer id);
}
